<template>
  <el-card>
    <!-- 面包屑 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/index' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>公共管理</el-breadcrumb-item>
      <el-breadcrumb-item>失物招领管理</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 搜索框 -->
    <el-row :gutter="30">
      <el-col :span="10">
        <el-input placeholder="请输入内容" v-model="queryInfo.keyWord" clearable @clear="getLostList">
          <el-button slot="append" icon="el-icon-search" @click="getLostList"></el-button>
        </el-input>
      </el-col>
      <el-col :span="4">
        <el-button type="primary" @click="addDialogVisible = true">发布招领信息</el-button>
      </el-col>
    </el-row>
    <!-- 主体 -->
    <el-table border stripe :data="lostList">
      <el-table-column type="index"></el-table-column>
      <el-table-column label="发布人" prop="studentName"></el-table-column>
      <el-table-column label="发布时间" prop="createTime"></el-table-column>
      <el-table-column label="招领信息概述" prop="lostTitle"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-tooltip effect="dark" content="查看" placement="bottom">
            <el-button type="primary" size="mini" icon="el-icon-tickets" @click="lookLostInfo(scope.row)"></el-button>
          </el-tooltip>
          <el-tooltip effect="dark" content="删除" placement="bottom">
            <el-button type="primary" size="mini" icon="el-icon-delete" @click="removeLost(scope.row)"></el-button>
          </el-tooltip>
        </template>
      </el-table-column>
    </el-table>
    <!-- 发布对话框 -->
    <el-dialog width="80%" title="发布招领信息" :visible.sync="addDialogVisible"> </el-dialog>
    <!-- 查看对话框 -->
    <el-dialog width="80%" :title="lostItem.lostTitle" :visible.sync="lookLostVisible">
      <div v-html="lostItem.lostDesc">
        {{ lostItem.lostDesc }}
      </div>
    </el-dialog>
  </el-card>
</template>

<script>
export default {
  data() {
    return {
      queryInfo: {
        keyWord: '',
        pageSize: '',
        pageIndex: ''
      },
      addDialogVisible: false,
      lookLostVisible: false,
      lostList: [
        {
          id: '235987545687100231',
          studentName: '路人甲',
          createTime: '2022-04-06 15:17:51',
          lostTitle: '捡到了一部手机',
          lostDesc: '4.3号上午在恒星大道捡到手机一台'
        }
      ],
      lostItem: {}
    }
  },
  methods: {
    // 获取全部招领信息
    getLostList() {},
    // 查看招领信息
    lookLostInfo(val) {
      console.log(val)
      this.lostItem = val
      this.lookLostVisible = true
    },
    // 删除招领信息
    async removeLost(val) {
      console.log(val)
      const confirmResult = await this.$confirm('此操作将永久删除该条信息，是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).catch((err) => err)
      console.log(confirmResult)
      if (confirmResult !== 'confirm') {
        return this.$message.info('已取消删除该招领信息')
      }
      //   调接口删除
    }
  }
}
</script>

<style lang="less" scoped></style>
